<?php

declare (strict_types = 1);

namespace own\auth;

use app\model\system\UserModel;

/**
 * 管理员
 */
class User
{
    private $auth;

    public function __construct()
    {
        $this->auth = request()->auth;
    }
    /**
     * 管理员信息
     */
    public function auth(): object
    {
        return $this->auth;
    }
    /**
     * 管理员id
     */
    public function uid(): int
    {
        return $this->auth->uid;
    }
    /**
     * 账号
     */
    public function getUser() 
    {
        return $this->auth->username;
    }
    /**
     * 超级管理员
     */
    public function super(): bool
    {
        return $this->auth->super ? true : false;
    }
    /**
     * 管理员角色id
     */
    public function roleId(): int
    {
        return UserModel::where('id', $this->auth->uid)->value('role_id');
    }
}